import searchicon from "imgs/searchicon.png";
import usePartState from "@module/usePartState";


export default function SearchInput(props) {
    const [stateObj, updateState] = usePartState({
        searchTxt:'',
    });
    const {searchTxt}=stateObj;


    function doSearch() {
        props.doSearch(searchTxt);
    }

    return(
        <div
            className={'bid-inputbid-search-wrapper'}
        >
            <img
                src={searchicon}
                className={"search-input-search-icon"}
            />
            <input
                type="text"
                className={"search-detail-searchcomp search-detail-searchcomp-border1"}
                placeholder={'请输入商品编号 / 商品名称'}
                onChange={e => {
                    updateState({
                        searchTxt:e.target.value
                    })
                }}
                onKeyUp={e=>{
                    if(e.keyCode==13){
                        doSearch()
                    }
                }}
            />
            <div
                onClick={doSearch}
                className={"search-input-comp"}
            >
                <p style={{ color: "#fff", fontSize: 14 }}>
                    搜索
                </p>
            </div>
        </div>
    )
}